// https://leetcode-cn.com/problems/third-maximum-number/

public int ThirdMax(int[] nums)
{
    long[] tmp = new long[3] { -2147483649, -2147483649, -2147483649 };
    for (int i = 0; i <= nums.Length - 1; i++)
    {
        if ((Array.IndexOf(tmp, nums[i]) == -1) && (nums[i] > tmp[0]))
        {
            tmp[0] = nums[i];
            Array.Sort(tmp);
        }
    }
    return tmp[0] == -2147483649 ? (int)tmp[2] : (int)tmp[0];
}